package com.anolesoft.ProductRegistration.mapper;

import com.anolesoft.ProductRegistration.entity.ProductFabrecordDO;
import com.anolesoft.amljmes.test.fenguangyingdu.entity.FabrecordDO;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.type.JdbcType;


@Mapper
public interface ProductFabrecordMapper {
//    @ResultMap("FabrecordResultMap")
public static String querySql=
        "select\n" +
                "t.fabrecordid,\n" +
                "t.xmh,\n" +
                "t.partid,\n" +
                "t.jx,\n" +
                "t.part_name as partName ,\n" +
                "t.putnum,\n" +
                "t.pgh2,\n" +
                "t.lupihao,\n" +
                "t.faliaoyuandate,\n" +
                "t.materialmark,\n" +
                "t.materialfmt,\n" +
                "b.gongyingshang as supplier ,\n" +
                "t.gongyiver\n" +
                "from (select * from MES_ORDER_TRACE a where a.fabrecordid = #{zhizaojilutiaoma,jdbcType=VARCHAR}) t \n" +
                "left join MES_OUTER_PLAN b on t.plnuid = b.objuid\n" +
                "where isfromtemp=2 and partstate=2 or partstate=0";
    public static String  StateQuerySql="select count(*) as num from mes_wx_djz where FABRECORDID=#{zhizaojilutiaoma,jdbcType=VARCHAR} and RETURNED_TYPE='外包完成返厂' and state!=1" ;

    @Select(querySql)
    ProductFabrecordDO selectFabrecordByCode(@Param("zhizaojilutiaoma") String zhizaojilutiaoma);
    @Select(StateQuerySql)
    String  selectState (@Param("zhizaojilutiaoma") String zhizaojilutiaoma) ;
    @Update("update MES_WX_DJZ set withdraw_user=#{login_user ,jdbcType=VARCHAR} , withdraw_date =sysdate , state=1 where  objuid=#{objuid,jdbcType=VARCHAR} ")
    void revocation(@Param("objuid") String objuid,@Param("login_user") String login_user);
}
